<script setup lang="ts">
const imgs = [
  'https://cdn.pixabay.com/photo/2017/08/07/08/23/sea-2601374_640.jpg',
  'https://cdn.pixabay.com/photo/2020/02/11/10/24/lake-4839058_640.jpg',
  'https://cdn.pixabay.com/photo/2024/02/21/08/06/coast-8587004_640.jpg',
  'https://cdn.pixabay.com/photo/2023/07/29/10/21/grasshopper-8156626_640.jpg',
];
</script>

<template>
  <div>
    <el-card class="mgb20">
      <template #header>基础用法</template>
      <div class="block text-center">
        <el-carousel height="400px">
          <el-carousel-item v-for="item in imgs" :key="item">
            <el-image class="carousel-img" :src="item" fit="cover" />
          </el-carousel-item>
        </el-carousel>
      </div>
    </el-card>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-card>
          <template #header>轮播图</template>

          <el-carousel trigger="click" height="300px">
            <el-carousel-item v-for="item in imgs" :key="item">
              <!-- <h3 class="small justify-center" text="2xl">{{ item }}</h3> -->
              <el-image class="carousel-img" :src="item" fit="cover"></el-image>
            </el-carousel-item>
          </el-carousel>
          <template #footer></template>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card>
          <template #header>卡片模式</template>
          <el-carousel :interval="4000" type="card" height="300px">
            <el-carousel-item v-for="item in imgs" :key="item">
              <el-image class="carousel-img" :src="item" fit="cover" />
            </el-carousel-item>
          </el-carousel>
          <!-- <template #footer></template> -->
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<style lang="scss" scoped>
.carousel-img {
  width: 100%;
  height: 100%;
}
.demonstration {
  color: var(--el-text-color-secondary);
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
